package essentials;

public class Logic {

    private Logic() {
    }

    public static Logic createLogic() {

        Logic logic;
        logic = new Logic();
        return logic;
    }

    public void updateOperationLog(Model m) {

        String oldFullInput = m.getFullInput();
        String newFullInput;
        if (oldFullInput != null) {
            newFullInput = oldFullInput + "\n" + m.getNewInput();
        } else {
            newFullInput = m.getNewInput();
        }
        m.setFullInput(newFullInput);
    }

    public Double berechneBMI(Model m) {
        Double bmi = null;
        double calculatedBmi;

        if (m.getGewicht() != null && m.getGroesse() != null) {
            calculatedBmi = m.getGewicht().doubleValue() / Math.pow(m.getGroesse().doubleValue(), 2.0d);
            bmi = new Double(calculatedBmi);
        }
        return bmi;
    }
}
